package com.fc.test.util.wx;

import com.fc.test.util.wx.Utils.OrderUtil;

import java.util.HashMap;
import java.util.Map;

public class GetJSSDKParameter {
	/**
	 * 支付页面授权
	 */
	public static final String WECHAT_FOR_SIGNATURE = "http://xiaohongmaoshare.com/pay.html";// 测试使用

	public static Map<String, Object> getWechatJsParameter(Map<String, Object> param) throws Exception {
		Map<String, Object> map = new HashMap<>();
		map.put("jsapi_ticket", WeiXinTokenThread.JSAPI_TICKET);
		map.put("timestamp", param.get("timestamp"));
		map.put("url", WECHAT_FOR_SIGNATURE);
		map.put("noncestr", param.get("noncestr"));
		// 排序
		String string1 = OrderUtil.sortParameters(map);
		// 拼接API秘钥
		String signature = OrderUtil.sha1(string1);
		map.put("signature", signature);
		map.put("appId", WxXcxPayService.appid);
		return map;
	}
}
